<?php

$this->breadcrumbs=array(
  'Catalogs'=>array('catalog/index/'),
  $model->title=>array('catalog/view/'.$model->id)
);
$this->catalog=$model;

?>

<div class="large-3 small-12 columns">
    <img src="<?php echo $model->pictures[0]->url; ?>">

    <div class="hide-for-small panel">
  		<h3><?php echo $model->title ?></h3>

  		<h6 class="subheader"><?php echo $model->description ?></h6>
      <?php if(isset($model->download_url)) {
        echo '<a href="'.$model->download_url.'"></a>';
      }?>
    </div>
</div>



<div class="large-9 columns table">
  	<?php
      foreach($model->catalogs as &$catalog){
        echo '<div class="row"><h3 class="larg-12 columns"><a href="'.$this->createUrl('catalog/view', array('id'=>$catalog->id)).'">'.$catalog->title.'</a></h3>';
        foreach($catalog->catalogItems as &$catalogItem){
          echo '<div class="large-4 small-6 columns">';
          echo $this->renderPartial('../_card', array('model'=>$catalogItem));
          echo '</div>';
        }
        echo '</div>';
      }
    ?>

  	<?php 
      $counter=0;
      echo '<div class="row">';
  		foreach ($model->catalogItems as &$catalogItem) {
  			//catalogItem

  			echo '<div class="large-4 small-6 columns" style="height: 100%">';
  			echo $this->renderPartial('../_card', array('model'=>$catalogItem));
  			echo '</div>';

        if(($counter+4)%3==0){
          echo '</div>';
          if($counter+1!=count($model->catalogItems)){
            echo '<div class="row">';
          }
        }

        $counter++;
  		}
      if($counter+1!=count($model->catalogItems)){
        echo '</div>';
      }
  	?>
</div>